/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author João Magalhães
 */
class SecurityFilters {

    def filters = {
        //teste/myProgramms_main
               
        filter1(controller: 'teste', action:'myProgramms_main') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter2(controller: 'teste', action:'myProgramms_canais') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter3(controller: 'teste', action:'myProgramms_alertas') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter4(controller: 'teste', action:'registration') {
            before = {
                
                if(session.user) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter5(controller: 'teste', action:'editProfile') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter6(controller: 'teste', action:'editAlert') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        
        filter7(controller: 'teste', action:'profile') {
            before = {
                
                if(session.user == null) {
                    redirect(controller: 'teste',action: 'startPage')
                    return false
                }
            }
        }
        /*

        filter12(controller: 'conference', action:'add22') {
            before = {

                if(session.user == null) {
                    redirect(controller: 'conference')
                    return false
                }
            }
        }

        filter13(controller: 'conference', action:'add2') {
            before = {

                if(session.user == null) {
                    redirect(controller: 'conference')
                    return false
                }
            }
        }



        filter2(controller: 'conference', action:'add2') {
            before = {

                def user = cm.User.get(session.user)
                def profile = cm.Profile.findByUser(user)

                 if(profile.conference == "0"){
                     redirect(controller: 'conference')
                     return false
                 }
            }
        }

        filter3(controller: 'conferenceUser', action:'manager') {
            before = {

                def user = cm.User.get(session.user)
                def profile = cm.Profile.findByUser(user)

                 if(profile.manager == "0"){
                     redirect(controller: 'conferenceUser')
                     return false
                 }
            }
        }*/
        

        }
}
